<html>
  <head>
    <link rel="stylesheet" type="text/css" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="/css/main.css" />
    <meta content={{ keywords }} name='keywords' />
    <meta content={{ description }} name="description" />
    <title>{{ title }}</title>
    <script type="text/javascript" src="//cdn.bootcss.com/jquery/2.0.1/jquery.min.js"></script>
  </head>

  <body>
    <!-- /.container-fluid -->
    <div class="container" style="margin-top: 60px">
      <div class="row">
        <div class="col-md-12">
          {% if flash.error%}
          <div class="alert alert-danger" role="alert">{{ flash.error }}</div>
          {% endif %}
          {% if task %}
          <div class="panel panel-default" >
            <div class="panel-heading">
              {{ task.attributes.name }}
            </div>
            <div class="panel-body">
              <ul class="list-group">
                <li class="list-group-item">描述：{{ task.attributes.description }}</li>
              </ul>
              <ul class="list-group">
                <li class="list-group-item">要求：{{ task.attributes.demand }}</li>
              </ul>

              <ul class="list-group">
                {% for task_list in task.list %}
                <li class="list-group-item">
                {{ task_list.attributes.name }}

                {% if task_list.attributes.complete %}
                <span class="label label-success {{ task_list.attributes._id.toString() }}">已完成</span>
                {% else %}
                <span class="label label-default {{ task_list.attributes._id.toString() }}">未完成</span>
                {% endif %}
                
                <input class="btn pull-right fileupload" style="margin-top: -5px" type="file" name="files[]" data-url="/task/uploadImage/{{ task_list.attributes._id.toString() }}" multiple>

                {% if task_list.attributes.image_url %}
                  {% if task_list.attributes.image_url.startsWith('/upload') %}
                  <img src="{{ task_list.attributes.image_url }}" class="{{ task_list.attributes._id.toString() }} pull-right img-thumbnail" style="width:30px;height: 30px;margin-top: -4px" />
                  {% elseif task_list.attributes.image_url.startsWith('huanping_') %}
                  <img src="http://7u2r0u.com2.z0.glb.qiniucdn.com/{{ task_list.attributes.image_url }}" class="{{ task_list.attributes._id.toString() }} pull-right img-thumbnail" style="width:30px;height: 30px;margin-top: -4px" />
                  {% endif %}
                
                {% else %}
                <img src="/images/default.png" class="{{ task_list.attributes._id.toString() }} pull-right img-thumbnail" style="width:30px;height: 30px;margin-top: -4px" />
                {% endif %}
                </li>
                {% endfor %}
              </ul>
            </div>
          </div>
          {% endif %}
        </div>
      </div>
    </div>
    
  </body>
  <script type="text/javascript" src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="/js/main.js"></script>
  <script type="text/javascript" src="/js/jquery.ui.widget.js"></script>
  <script type="text/javascript" src="/js/jquery.iframe-transport.js"></script>
  <script type="text/javascript" src="/js/jquery.fileupload.js"></script>
  <script type="text/javascript">
  $(function () {
    $('.fileupload').each(function () {
      $(this).fileupload({
        dropZone: $(this),
        done:function(err,data){
          var id = data.result.id;
          $('img.'+id).attr('src',data.result.path);
          $('span.'+id).removeClass('label-default').addClass('label-success');
          $('span.'+id).text('已完成');
        }
      });
    });
  });

  </script>
</html>